import { reqAddressInfo,reqOrderInfo } from "@/api"
const state={
    address:[],
    orderinfo:{}
}
const mutations={
    //地址
    GETUSERADDRESS(state,data){
        state.address=data
    },
    //订单信息
    GETORDERINFO(state,data){
        state.orderinfo=data
    }
}
const actions={
    //获取用户地址信息
    async getUserAddress({commit}){
        let result= await reqAddressInfo()
        if (result.code==200) {
            commit('GETUSERADDRESS',result.data)
            return 'ok'
        }else{
            return Promise.reject(new Error('faile'))
        }
    },
    //获取订单交易也清单
    async getOrderInfo({commit}){
        let result=await reqOrderInfo()
        if (result.code==200) {
            commit('GETORDERINFO',result.data)
            return 'ok'
        }else{
            return Promise.reject(new Error('faile'))
        }
        
    }
}
const getter={

}
export default{
    state,
    mutations,
    actions,
    getter
}